package suites.integration {
	import org.flexunit.asserts.assertEquals;
	import org.splink.library.queue.QEvent;
	import org.splink.resource.ResourceProvider;

	/**
	 * @author Max Kugland
	 */
	public class LocaleFallbackTest extends AbstractIntegrationTest {
		
		[Test (async)]
		public function nonExistentLocale() : void {
			handleAsync(1000);
			
			var xml : XML = <resourcebundles defaultLocale="de_DE">
								<resourcebundle locale="de_DE" />
							</resourcebundles>;
							
			createProcessor(xml, function(e : QEvent) : void {
				assertEquals("de_DE", ResourceProvider.instance().currentLocale);
			}, "en_EN").start();
		}
		
		[Test (async)]
		public function existingLocale() : void {
			handleAsync(1000);
			
			var xml : XML = <resourcebundles defaultLocale="en_US">
								<resourcebundle locale="de_DE" />
								<resourcebundle locale="en_US" />
							</resourcebundles>;
							
			createProcessor(xml, function(e : QEvent) : void {
				assertEquals("de_DE", ResourceProvider.instance().currentLocale);
			}, "de_DE").start();
		}
		
		[Test (async)]
		public function existingNestedLocale() : void {
			handleAsync(1000);
			
			var xml : XML = <resourcebundles defaultLocale="en_US">
								<resourcebundle locale="de_DE" >
									<locales>
										<locale value="at_DE" />
									</locales>
								</resourcebundle>
							</resourcebundles>;
							
			createProcessor(xml, function(e : QEvent) : void {
				assertEquals("at_DE", ResourceProvider.instance().currentLocale);
			}, "at_DE").start();
		}
	}
}
